package com.xingkeduo.business.user.controller;

import com.xingkeduo.business.transformation.json.CraftsmanJTO;
import com.xingkeduo.business.transformation.json.CraftsmanJobJTO;
import com.xingkeduo.business.transformation.json.CraftsmanServiceJTO;
import com.xingkeduo.business.transformation.json.CraftsmanSocialJTO;
import com.xingkeduo.business.user.domain.ManageInfoDomain;
import com.xingkeduo.pojo.query.CraftsmanJobQO;
import com.xingkeduo.pojo.query.CraftsmanQO;
import com.xingkeduo.pojo.query.CraftsmanServiceQO;
import com.xingkeduo.pojo.query.CraftsmanSocialQO;
import com.xingkeduo.pojo.table.CraftsmanTO;
import com.xingkeduo.util.pojo.base.BaseController;
import com.xingkeduo.util.pojo.domain.Page;
import com.xingkeduo.util.pojo.domain.PageJTO;
import com.xingkeduo.util.tool.ReturnUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 一线员工 列表
 *
 * @author 高杰
 * @time 2019年1月7日 下午6:57:47
 * @description
 */
//@CrossOrigin
@RestController
@RequestMapping("/craftsman/page/list")
public class CmsCraftsmanListController extends BaseController {
	private final Logger log = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private ManageInfoDomain manageInfoDomain;

	/**
	 * 分页 查询条件
	 * 
	 * @param url:
	 * @param page:
	 * @param limit:
	 * @return : java.lang.String
	 * @author : gaozifeng
	 * @date : 2019/3/4 16:51
	 */
	@GetMapping(value = "/{url:.+}")
	public String doGet(@PathVariable String url, int page, int limit) {
		returnUtil = new ReturnUtil();
		try {
			CraftsmanQO craftsmanQuery = CraftsmanJTO.createQueryForStatuss(url);
			CraftsmanJobQO craftsmanJobQuery = CraftsmanJobJTO.createQueryForList(url);
			CraftsmanSocialQO craftsmanSocialQuery = CraftsmanSocialJTO.createConditionList(url);
			CraftsmanServiceQO craftsmanServiceQuery = CraftsmanServiceJTO.createQueryForCraftsmanList(url);
			Page<CraftsmanTO> pageDO = new Page<CraftsmanTO>(page, limit);
			log.info("请求发型师列表url -------"+url+",--------------page "+page+",-=-------------limit"+limit);
			return returnUtil.getSuccess(PageJTO.toJson(pageDO, CraftsmanJTO.toJson(manageInfoDomain
					.getCraftsmansPage(craftsmanQuery, craftsmanJobQuery, craftsmanServiceQuery, craftsmanSocialQuery, pageDO))));
		} catch (Throwable t) {
			return dealException(t, returnUtil);
		}
	}
}
